package org.example.spring.aop.advice;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class FirstAdvice {

    @Pointcut("execution(* org.example.spring.aop.tager.*.*(..))")
    private void abc() {}
    @AfterReturning("abc()")
    public void afterReturn() {
        System.out.println("提交了");
    }
    @Before("abc()")
    public void before() {
        System.out.println("我在你之前执行了");
    }

    @Around("abc()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("我是环绕之前");
        //执行目标对象的方法
        Object proceed = pjp.proceed();
        System.out.println("我是环绕之后");
        return proceed;
    }
    @After("abc()")
    public void after(){
        System.out.println("我是最终的通知");
    }

    @AfterThrowing("abc()")
    public void exception() {
        System.out.println("你的代码出现错误");
    }
}
